<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core" template="../index.xhtml">

	<h:head>
		<f:facet name="first">
			<meta content='text/html; charset=UTF-8' http-equiv="Content-Type" />
			<title>Sistema UTI Neonatal</title>
		</f:facet>
	</h:head>

	<ui:define name="content">

		<p:accordionPanel id="accGerenciarSintomas" activeIndex="0"
			multiple="true">

			<p:tab title="Gerenciar Sintomas">

				<h:form id="formTableSintomas">

					<p:growl id="messages" showDetail="true" />

					<p:dataTable id="tableSintomas" var="sintoma"
						value="#{sintomaController.sintomaModel}" paginator="true" rows="5"
						selection="#{sintomaController.sintoma}" selectionMode="single"
						paginatorPosition="bottom" widgetVar="sintomaTable" emptyMessage="Nenhum registro encontrado!">

						<p:ajax event="rowSelect"
							update=":accGerenciarSintomas:formDialogSintoma:crudSintoma"
							oncomplete="dialogGerSintoma.show()" />

						<f:facet name="header">
							<h:outputText value="Pesquisar: "
								style="margin-left:4px;margin-top:4px;float:left;position:relative" />
							<p:inputText id="globalFilter"
								style="margin-left:3px;float:left;position:relative;width:150px" value="#{sintomaController.sintomaPesq.descricao}" />
							<p:commandButton id="botaoPesquisar" icon="ui-icon-search"
									update=":accGerenciarSintomas:formTableSintomas:tableSintomas"
									oncomplete="dialogGerSintoma.hide();"
									actionListener="#{sintomaController.pesquisarSintoma}"
								style="margin-left:4px;margin-top:2px;width:20px;height:20px;float:left;position:relative"></p:commandButton>
						</f:facet>

						<p:column id="identificadorColumn" headerText="Identificador" style="width: 50%">
							<h:outputText value="#{sintoma.id}" />
						</p:column>

						<p:column id="descricaoColumn" headerText="Descrição" style="width: 50%">
							<h:outputText value="#{sintoma.descricao}" />
						</p:column>
						
						<p:column id="tipoSintomaColumn" headerText="Tipo do Sintoma Associado" style="width: 50%">
							<h:outputText value="#{sintoma.tipoSintoma.descricao}" />
						</p:column>

					</p:dataTable>

				</h:form>

				<p:dialog header="Gerencia de Sintoma" widgetVar="dialogGerSintoma"
					resizable="false" showEffect="slide" width="650">

					<h:form id="formDialogSintoma" prependId="false">

						<h:panelGrid id="crudSintoma" columns="2" style="margin-top:10px">

							<f:facet name="header">
								<p:messages />
							</f:facet>

							<h:outputLabel for="descricao" value="Descrição:"
								style="margin-top:40px" />
							<h:inputText id="descricao"
								value="#{sintomaController.sintoma.descricao}" required="true"
							requiredMessage="Descrição é campo obrigatório! Favor preencher."/>
								
							<h:outputLabel for="tipoSintomaAlterar" value="Tipo do Sintoma:"
								style="margin-top:40px" /> 
							<h:selectOneMenu id="tipoSintomaAlterar" value="#{sintomaController.tipoSintomaSelecionado}" converter="IndexedConverter">
								<f:selectItems value="#{sintomaController.listaTipoSintomas}"/>		
							</h:selectOneMenu>	
								
							<div style="margin-top: 20px"></div>
							<f:facet name="footer">
								<p:commandButton
									update=":accGerenciarSintomas:formTableSintomas:tableSintomas :accGerenciarSintomas:formTableSintomas:messages"
									oncomplete="dialogGerSintoma.hide();"
									actionListener="#{sintomaController.alterarSintoma}"
									value="Alterar Sintoma" />
								<p:commandButton value="Remover Sintoma"
									update=":accGerenciarSintomas:formRemover"
									oncomplete="remover.show()" />
							</f:facet>

						</h:panelGrid>

					</h:form>

				</p:dialog>

				<p:dialog widgetVar="remover" header="Remover Sintoma" width="500"
					resizable="false" showEffect="slide">

					<h:form id="formRemover">

						<h:outputText
							value="Tem certeza que quer remover: #{sintomaController.sintoma.descricao} ?" />

						<h:panelGrid columns="2" style="margin-top:20px">

							<p:commandButton value="Sim"
								actionListener="#{sintomaController.excluirSintoma}"
								update=":accGerenciarSintomas:formTableSintomas:tableSintomas :accGerenciarSintomas:formTableSintomas:messages"
								oncomplete="dialogGerSintoma.hide(), remover.hide()" />
							<p:commandButton value="Não" onclick="remover.hide()" />

						</h:panelGrid>

					</h:form>

				</p:dialog>

			</p:tab>

			<p:tab id="tabCriarSintoma" title="Criar Sintoma">

				<h:form id="formCriaSintoma" prependId="false">

					<h:panelGrid id="criaSintoma" columns="3" style="margin-top:20px">

						<h:outputLabel for="descricao" value="Descrição:" />

						<p:inputText id="descricaoCriar"
							value="#{sintomaController.novoSintoma.descricao}" required="true"
							requiredMessage="Descrição é campo obrigatório! Favor preencher." />
						<br />
							
						<h:outputLabel for="tipoSintomaAdicionar" value="Tipo do Sintoma:"
								style="margin-top:40px" /> 
						<h:selectOneMenu id="tipoSintomaAdicionar" value="#{sintomaController.tipoSintomaSelecionado}" converter="IndexedConverter">
							<f:selectItems value="#{sintomaController.listaTipoSintomas}"/>		
						</h:selectOneMenu>
						<br />	


						<f:facet name="footer">
							<p:commandButton
								update=":accGerenciarSintomas:formTableSintomas:tableSintomas :accGerenciarSintomas:formCriaSintoma:criaSintoma :accGerenciarSintomas:formTableSintomas:messages"
								oncomplete="dialogGerSintoma.hide();"
								actionListener="#{sintomaController.adicionarSintoma}"
								value="Criar Sintoma" style="margin-top:20px" />
						</f:facet>

					</h:panelGrid>

				</h:form>

			</p:tab>

		</p:accordionPanel>

	</ui:define>
</ui:composition>